class HistoryController < ApplicationController

  def show
    @history = History.find(params[:id])
    
    @newTask = Task.new
    @newTask.history_id = @history.id
    @newTask.day = Date.today
    
    #excerpt(text, phrase, radius = 100, excerpt_string = "...")
  end

  def updateTask
     @history = History.find(params[:id])
     
    @task = Task.new(params[:task])
    @task.save
    redirect_to(@history)
    
  end


  def new
    @history = History.new
    @history.sprint_id = params[:sprint_id]
  end
  
  # POST /sprints
  # POST /sprints.xml
  def create
    @history = History.new(params[:history])

    respond_to do |format|
      if @history.save
        flash[:notice] = 'History added.'
        format.html { redirect_to(@history.sprint) }
        format.xml  { render :xml => @history, :status => :created, :location => @history }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @history.errors, :status => :unprocessable_entity }
      end
    end
  end
  
  
  # PUT /sprints/1
  # PUT /sprints/1.xml
  def update
    @history = History.find(params[:id])

    respond_to do |format|
      if @history.update_attributes(params[:history])
        flash[:notice] = 'History was successfully updated.'
        format.html { redirect_to(@history) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @history.errors, :status => :unprocessable_entity }
      end
    end
  end  
  
  
  def edit
    @history = History.find(params[:id])
  end
  

end
